﻿using System;
using System.Data;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Collections;
using Dcms.BLL;
using Dcms.Common;
using Dcms.Model;
using WebApp.AppCode;

public partial class Manage_Modle_Position_JobSeekerList : System.Web.UI.Page
{
    public CompetenceLib CL = new CompetenceLib();
    Dcms_JobSeekerBLL jBll = new Dcms_JobSeekerBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        
        CL.IsLogin();
       // try
       // {
            if (!IsPostBack)
            {
                if (Request.QueryString["Key"] != null)
                {
                    string Key = Request.QueryString["Key"].ToString().Replace("{|}","%");
                    //this.hidAmount.Value = SqlHelper.GetNoteCount("select count(*) from Secretary Where " + Key).ToString();
                    //this.hidSql.Value = "select * from Secretary Where " + Key + "Order by Sec_CertTime Desc";
                }
                else
                {
                    this.hidAmount.Value = jBll.GetDataCount("select count(*) from Dcms_JobSeeker").ToString();
                    this.hidSql.Value = "select * from Dcms_JobSeeker Order by Js_AddTime Desc";
                }
                ReBinder(1);

            }
       // }
       // catch (Exception ex)
       // {
          //  Log.LogHandler.LogError("Manage_Modle_Position_JobSeekerList.Page_Load", ex);
          //  throw ex;
        //}
    }
    protected void BindRpt(object sender, PagingEventArgs e)
    {
        this.ReBinder(e.pageIndex);
    }

    private void ReBinder(int PageIndex)
    {
        this.repIntor.DataSource = jBll.GetDataListByPage(this.hidSql.Value, PageIndex, 10);
        this.repIntor.DataBind();
        pagingctrl.InitPc(Convert.ToInt32(this.hidAmount.Value), PageIndex, 10);
    }

    public String GetStrLeng(String Str)
    {
        return Utils.GetSubString(Str, 30, "...");
    }
    public String FormatDateTimeMy(String Str)
    {
        return Convert.ToDateTime(Str).ToString("yyyy-MM-dd");
    }

    protected void repnew_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            Literal lit = (Literal)e.Item.FindControl("lit_Sex");
            if (Convert.ToInt32(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "Js_Sex")) == 1)
            {
                lit.Text = "男";
            }
            else
            {
                lit.Text = "女";
            }
            ((LinkButton)e.Item.FindControl("HypDelete")).Attributes.Add
                   ("onclick", "return confirm('确定要删除该记录吗？');");
            if (CL.IsDelete(Convert.ToInt32(strCatID)) == false)
            {
                ((LinkButton)e.Item.FindControl("HypDelete")).Visible = false;
            }
        }
    }

    protected void repnew_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            if (e.CommandName == "delete")
            {
                jBll.DeleteModelByID(Convert.ToInt32(((HiddenField)e.Item.FindControl("hidID")).Value));
                Response.Redirect("JobSeekerList.aspx",false);
            }
        }
    }
	  private string strCatID
    {
        get
        {
            return Request.QueryString["CatID"] + "";
        }
    }
}
